import {createStore} from 'vuex';

export default createStore({
    state: {
        editableTabsValue: '/dashBoard',
        editableTabs: [{
            title: 'DashBoard',
            name: '/dashBoard',
        }],
        imgUrl: "",// 添加 imgUrl 状态
        blackStatus: false, // 添加暗色模式状态管理
        asideStatus: false, // 添加侧边栏折叠状态管理
    },
    getters: {
        getImgUrl: (state) => state.imgUrl, // 添加 getter 来获取 imgUrl
        getBlackStatus: (state) => state.blackStatus, // 添加 getter 来获取 blackStatus
        getAsideStatus: (state) => state.asideStatus, // 添加 getter 来获取 asideStatus
    },
    mutations: {
        ADD_TABS: (state, tab) => {
            if (state.editableTabs.findIndex(e => e.name === tab.path) === -1) {
                state.editableTabs.push({
                    title: tab.name,
                    name: tab.path,
                });
            }
            state.editableTabsValue = tab.path;
        },
        RESET_TABS: (state) => {
            state.editableTabsValue = '/dashBoard';
            state.editableTabs = [
                {
                    title: 'DashBoard',
                    name: '/dashBoard',
                }
            ];
        },
        SET_IMG_URL: (state, url) => {
            state.imgUrl = url; // 添加 mutation 来设置 imgUrl
        },
        SET_BLACK_STATUS: (state, status) => {
            state.blackStatus = status; // 添加 mutation 来设置 blackStatus
        },
        SET_ASIDE_STATUS: (state, status) => {
            state.asideStatus = status; // 添加 mutation 来设置 asideStatus
        }
    },

    actions: {},
    modules: {}
});
